package vision.nvhuong.dao;

import java.io.Serializable;
import java.util.List;

import javax.persistence.EntityManager;

/**
 * The foundation of using a Generic DAO is the CRUD operations that perform on
 * each entity
 * @author nvhuong
 *
 * @param <T>
 * @param <PK>
 */
public interface BaseDao<T, PK extends Serializable> {
	//create
	public T persist(T entity,EntityManager em);

	//delete
	public T remove(T entity,EntityManager em);
	
	 //update
    public T refresh(T entity,EntityManager em);

	public T findById(PK id,EntityManager em);
	
	public T merge(T entity,EntityManager em);	
	 
    public List<T> findAll(EntityManager em);
 
    public Long getTotalResult(EntityManager em);
    
    public List<T> persistList(List<T> entityList,EntityManager em);
    
    public List<T> removeList(List<T> entityList,EntityManager em);

}
